/*
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author       Notes
 * 2024-09-15     Tian Yiqing      first implementation
 */

#ifndef __DRV_ADC_H__
#define __DRV_ADC_H__

#include <rthw.h>
#include <rtthread.h>
#include <board.h>
#include "drv_gpio.h"
#include "drv_dma.h"

#ifdef __cplusplus
extern "C" {
#endif

#define MAX_EXTERN_ADC_CHANNEL    16

struct gd32_adc_channel_pin
{
    rcu_periph_enum chn_pin_clk;
    rt_uint32_t chn_pin_periph;
    rt_uint32_t chn_pin;
};

/* gd32 adc dirver class */
struct gd32_adc
{
    char *device_name;
    uint32_t adc_periph;
    rcu_periph_enum adc_clk;
    struct rt_adc_device *adc_dev;
    struct gd32_adc_channel_pin adc_chn_pins[MAX_EXTERN_ADC_CHANNEL];
    uint32_t resolution;
#ifdef BSP_ADC_USING_DMA
    dma_config_t *dma_configs;
    uint16_t cur_data;
#endif
    struct rt_completion adc_compl;
};

#ifdef __cplusplus
}
#endif

#endif /* __DRV_ADC_H__ */
